using System;
using System.Collections.Generic;
using System.Text;
using CommonTypes;
using MVCFramework;

namespace BuildingStructuralElements
{
    [Serializable ]
    public class Support  : StructuralElement
    {

        # region " Imodifiable Implementation "

        public override bool Move(Vector v)
		{
			return SupportedNode .Move (v );
		}
		
		public override bool Move(double dx, double dy, double dz)
		{
			return SupportedNode .Move (dx,dy,dz);
        }

        # endregion 

        Node supportedNode;

        public Node SupportedNode
        {
            get { return supportedNode; }
        }

        protected Constrain SuportConstraint
        {
            get { return supportedNode[this]; }
            set { supportedNode[this] = value; }
        }

        public Support(Node supportedNode):base ()
        {
            this.supportedNode = supportedNode;
            this.SuportConstraint = new Constrain(true, true, true, true, true, true);
        }

        #region "delegate functionality to supported node constraint "
 
        public bool Dx
        {
            get { return SuportConstraint.Dx; }
            set { SuportConstraint.Dx = value; }
        }

        public bool Dy
        {
            get { return SuportConstraint.Dy; }
            set { SuportConstraint.Dy = value; }
        }

        public bool Dz
        {
            get { return SuportConstraint.Dz; }
            set { SuportConstraint.Dz = value; }
        }

        public bool Rx
        {
            get { return SuportConstraint.Rx; }
            set { SuportConstraint.Rx = value; }
        }

        public bool Ry
        {
            get { return SuportConstraint.Ry; }
            set { SuportConstraint.Ry = value; }
        }

        public bool Rz
        {

            get { return SuportConstraint.Rz; }
            set { SuportConstraint.Rz = value; }
        }

        #endregion 

        # region " operators Implemetation " 
        public static bool operator ==(Support suport1, Support suport2)
        {
            object o1 = suport1;
            object o2 = suport2;

            if (o1 == null && o2 == null) return true;
            if (o1 == null) return false;
            if (o2 == null) return false;

            if (suport1.supportedNode == suport2 .supportedNode)
                return true;
            else
                return false;

        }

        public static bool operator !=(Support support1, Support support2)
        {
            return !(support1 == support2);
        }

        public override bool Equals(object obj)
        {
            if (obj is Support)
                return (bool)(this == (Support)obj);
            else return false;
        }
        #endregion
    }
}
